<!DOCTYPE html>
<html>
<head>
    <#include "common.ftl">
</head>
<script type="text/javascript" src="${ctx}/echarts/echarts.min.js"></script>
<script type="text/javascript" src="${ctx}/lib//jquery-3.4.1/jquery-3.4.1.min.js">
    <script type="text/javascript" src="${ctx}/bootstrap/js/bootstrap.js"></script>
<body class="childrenBody">
<div class="layui-container">
    <div id="main1" style="height:400px;"></div>
    <div id="main" style="height:400px;">
    </div>
</div>
<script type="text/javascript">
    var url1 = ctx + "/discount/discountCount";
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    $.post(url1, function (data) {
        var option = {
            title: {
                text: '优惠券发布图'
            },
            tooltip: {},
            legend: {
                data: ['销量']
            },
            xAxis: {
                data: data.listName
            },
            yAxis: {},
            series: [
                {
                    name: '优惠券数量',
                    type: 'bar',
                    data: data.listCount
                }
            ]
        };
        myChart.setOption(option);
    });
    // 指定图表的配置项和数据

    var url2 = ctx + "/product/productCount"
    // 使用刚指定的配置项和数据显示图表。
    var myChart1 = echarts.init(document.getElementById('main1'));
    $.post(url2, function (data) {
        console.log(data.listNameP[1]);
       var  option1 = {
            title: {
                text: '商品类型数量统计',
                left: 'center'
            },
            tooltip: {
                trigger: 'item'
            },
            legend: {
                orient: 'vertical',
                left: 'left'
            },
            series: [
                {
                    name: 'Access From',
                    type: 'pie',
                    radius: '80%',
                    data: [
                        { value: data.listCountP[0], name: data.listNameP[0] },
                        { value: data.listCountP[1], name: data.listNameP[1] },
                        { value: data.listCountP[2], name: data.listNameP[2] },
                        { value:  data.listCountP[3], name: data.listNameP[3] },

                    ],
                    emphasis: {
                        itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        myChart1.setOption(option1);
    });


</script>
</body>
</html>
